#!/usr/bin/python
# coding=utf-8
import commands,re

def kill_process(keyword):
    cmd = "ps ax |grep '%s'" %(keyword,)
    (status,output) = commands.getstatusoutput(cmd)

    keyword = re.compile(r'\d+')
    #print "output:\n%s\n\n" %output
    for line in output.split('\n'):
        if line.find("grep") ==  -1:
            #print line
            str_list = keyword.findall(line)
            if len(str_list):
                #print "str_list: %s" % str_list
                cmd = "kill -9 %s" %(str_list[0],)
                print cmd
                (status,output) = commands.getstatusoutput(cmd)
                
